package com.cy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cy.entity.Book;
import com.cy.entity.BookDictionary;
import com.cy.entity.Dictionary;
import com.cy.mapper.BookDictionaryMapper;
import com.cy.mapper.BookMapper;
import com.cy.mapper.DictionaryMapper;
import com.cy.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author : 残影
 * @Date: 2021-02-23 14:21
 */
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {
    @Autowired
    private BookDictionaryMapper bookDictionaryMapper;
    @Autowired
    private DictionaryMapper dictionaryMapper;
    @Override
    public List<BookDictionary> getchapterByBookId(String bookId) {
        QueryWrapper<BookDictionary> bookDictionaryQueryWrapper = new QueryWrapper<>();
        bookDictionaryQueryWrapper.select("DISTINCT tag").eq("book_id",bookId);
        return bookDictionaryMapper.selectList(bookDictionaryQueryWrapper);
    }

    @Override
    public List<Dictionary> getVocabulary(String bookId, String tag) {
        return dictionaryMapper.getVocabulary(bookId,tag);
    }
}
